<template>
	<view class="container">
		<view class="tip-blue" v-if="haveTip"></view>
    <text  v-if="noTab" class="tip-text">报警</text>
		<view  v-if="!noTab"  class="item" @click="handleListBarTitleClick('0')">
		  <view :class="[isFirst ? 'select-title':'normal-title']">{{isDevices ?onlineText :incompletedText}}</view>
		  <view :class="[isFirst ? 'select-underline':'space-underline' ]"></view>
		</view>
		<view v-if="!noTab" class="item" @click="handleListBarTitleClick('1')">
		  <view :class="[!isFirst ? 'select-title':'normal-title']"> {{isDevices ?offlineText :completedText}}</view>
		  <view :class="[!isFirst ? 'select-underline':'space-underline' ]"></view>
		</view>
		<view class="flex"></view>
		<view v-if="haveRightCell" class="right-cell" @click='handleNextContentClick()'>
			<view >{{ rightText }}</view>
			<uni-icons type="right" size="20" v-if="rightIcon"></uni-icons>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
      rightIcon: {
        type: Boolean,
        default: false
      },
      noTab: {
        type: Boolean,
        default: false
      },
			haveRightCell: {
				type: Boolean,
				default: false
			},
			isDevices: {
				type: Boolean,
				default: false
			},
			haveTip: {
				type: Boolean,
				default: false
			},
			incompletedNumber: {
				type: Number,
				default: 0
			},
			completedNumber: {
				type: Number,
				default: 0
			},
			onlineNumber: {
				type: Number,
				default: 0
			},
			offlineNumber: {
				type: Number,
				default: 0
			},
			rightText: {
				type: String,
				default: '更多'
			},
			tabIndex: {
				type: String,
				default: '0'
			}
		},
    watch: {
      tabIndex: {
        immediate: true,
        handler (val) {
          console.log('val>>',  val)
        }
      },

    },
    data(){
        return {

        }
    },
		computed: {
      isFirst(){
        return  this.tabIndex == '0'
      },
			incompletedText() {
				return '待处理(' + this.incompletedNumber + ')'
			},
			completedText() {
				return '已处理(' + this.completedNumber + ')'
			},
			onlineText() {
				return '在线(' + this.onlineNumber + ')'
			},
			offlineText() {
				return '离线(' + this.offlineNumber + ')'
			}
		},
		methods: {

			handleListBarTitleClick(tabIndex) {

				this.$emit('handleListBarTitleClick',String(tabIndex));
			},
			handleNextContentClick() {
				this.$emit('handleNextContentClick');
			}
		}
	}
</script>

<style>
	.container {
		margin-top: 15rpx;
		padding-left: 15rpx;
		padding-right: 15rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-left: 10rpx;
		padding-right: 10rpx;
		margin-left: 10rpx;
		height: 100rpx;

	}

	.select-title {
		color: #1654ff;
		font-size: 30rpx;
		font-weight: 500;
	}

	.normal-title {
		color: #333333;
		font-size: 30rpx;
		font-weight: 500;
	}

	.title {
		font-size: 40rpx;
		margin-right: 20rpx;
	}

	.select-underline {
		height: 5rpx;
		width: 100rpx;
		background-color: #1654ff;
		margin-top: 5rpx;
	}
	.space-underline {
		height: 5rpx;
		margin-top: 5rpx;
		width: 100rpx;
	}
	.flex {
		flex: 1;
	}
	.right-cell{
		display: flex;
		height:40rpx;
		flex-direction: row;
		align-self: center;
    align-items: center;
	}
	.space {
		width: 20rpx;
	}
	.tip-blue {
		margin-right: 10rpx;
		height: 30rpx;
		width: 6rpx;
		border-radius: 2rpx;
		background-color: #1654ff;
	}


</style>